$(function(){
	// 搜索切换
	$('.nav-tabs05 li').click(function(){
		$(this).addClass('active').siblings('li').removeClass('active');
	});

	// 首页点击跨库检索范围弹窗
	$('.dialog-p').click(function(){
		$('.talkDiv').removeClass('hidden');
		// 点击全选
		$('.select-all').click(function(){
			$('.talkDivLi .f-checkbox').attr('checked','checked');
		});
		// 点击取消
		$('.cancel').click(function () {
		    $('.talkDivLi .f-checkbox').removeAttr('checked', 'checked');
		    //$(this).parent().parent().addClass('hidden');
		});
		// 点击关闭
		$('.icon-close').click(function(){
			$(this).parent().parent().addClass('hidden');
		});
	});

	// 追加一条
	$('.iconfont-add').click(function(){
		$('.s-topic').last().clone().appendTo('.wrap-r-t fieldset');
	});
	// 删减一条
	$('.iconfont-minus').click(function(){
		$('.s-topic').last().remove();
	});

	// 排序切换
	$('.taxis a').click(function(){
		$(this).addClass('cur').siblings('a').removeClass('cur');
	});

	// 列表摘要
	$('.lb a').click(function(){
		$(this).addClass('cur').siblings('a').removeClass('cur');
	});

	// 点击收藏
	$('.iconfont.iconfont-star-empty').parent('.f-label').click(function(){
		$(this).children('.iconfont.iconfont-star-empty').toggleClass('iconfont-star');
	});

	// 论文细览页
	$('.doc-ewm').hover(function(){
		$('.doc-ewm-l').css('visibility','visible');
	},function(){
		$('.doc-ewm-l').css('visibility','hidden');
	});

	// 轮播
 		var nowshowpic = 0;
			$("#picList ul").html( $("#picList ul").html() + $("#picList ul").html() );

			$("#next").click(
				function(){
					if(!$("#picList ul").is(":animated")){
						if(nowshowpic == $("#picList ul li").length - 9){
							nowshowpic = 0;
							carouselShow2();
						}else{
							nowshowpic = nowshowpic + 1;
							carouselShow(nowshowpic);
						}
						
					}
				}
			);

			$("#prev").click(
				function(){
					if(!$("#picList ul").is(":animated")){
						if(nowshowpic == 0){
							nowshowpic = $("#picList ul li").length - 9;
							carouselShow3();
						}else{
							nowshowpic = nowshowpic - 1;
							carouselShow(nowshowpic);
						}
						
					}
				}
			);

			function carouselShow(nowshowpic){
			 	$("#picList ul").animate(
			 		{
			 			"left":-188 * nowshowpic
			 		},500
			 	);
			}

			function carouselShow2(){
			 	$("#picList ul").animate(
			 		{
			 			"left":-188 * ($("#picList li").length - 8)
			 		},500,function(){
			 			$("#picList ul").css("left",0);
			 		}
			 	);
			}
			function carouselShow3(){
				$("#picList ul").css("left",-99 * ($("#picList li").length - 8));
				$("#picList ul").animate(
			 		{
			 			"left":-188 * ($("#picList li").length - 9)
			 		},500
			 	);
			}





			$("#picBox li").mouseenter(
 			function(){
 				$(this).children(".zhezhao").fadeIn();
 			}
 		).mouseleave(
 			function(){
 				$(this).children(".zhezhao").fadeOut();
 			}
 		);


 		// 底部小圆点轮播
 		var picW=247;
	$('.huxi1 .tupianliebiao ul li a').width(picW);
	var nowshowpic = 0;
			//复制一个第一个li在最后，用于变魔术
			$(".huxi1 .tupianliebiao ul").each(function(){
				//$(this).html( $(this).html() + $(this).html() );
			});
			// $(".tupianliebiao ul").html( $(".tupianliebiao ul").html() + $(".tupianliebiao ul").html() );

			$(".huxi1 .rightanniu").click(
				function(){
					if(!$(".huxi1 .tupianliebiao ul").is(":animated")){
						if(nowshowpic == $(".huxi1 .tupianliebiao ul li").length - 2){
							nowshowpic = 0;
							lunboxianshi2();
						}else{
							nowshowpic = nowshowpic + 1;
							lunboxianshi(nowshowpic);
						}
						shezhixiaoyuandian(nowshowpic);
					}
				}
			);

			$(".huxi1 .leftanniu").click(
				function(){
					if(!$(".huxi1 .tupianliebiao ul").is(":animated")){
						if(nowshowpic == 0){
							nowshowpic = $(".huxi1 .tupianliebiao ul li").length - 2;
							lunboxianshi3();
						}else{
							nowshowpic = nowshowpic - 1;
							lunboxianshi(nowshowpic);
						}
						
						shezhixiaoyuandian(nowshowpic);
					}
				}
			);
			$(".huxi1 .xiaoyuandianul li").click(
				function(){
					var x=$(this);
					nowshowpic = $(this).index();
					lunboxianshi(x,nowshowpic);
					shezhixiaoyuandian(x,nowshowpic);
				}
			);

			function lunboxianshi(y,nowshowpic){
			 	y.parent().parent().siblings('.tupianliebiao').children('ul').animate(
			 		{
			 			"left":-picW * nowshowpic
			 		},500
			 	);
			}

			function lunboxianshi2(){
			 	$(".huxi1 .tupianliebiao ul").animate(
			 		{
			 			"left":-picW * ($(".huxi1 .tupianliebiao li").length - 1)
			 		},500,function(){
			 			$(".huxi1 .tupianliebiao ul").css("left",0);
			 		}
			 	);
			}
			function lunboxianshi3(){
				$(".huxi1 .tupianliebiao ul").css("left",-picW * ($(".huxi1 .tupianliebiao li").length - 1));
				$(".huxi1 .tupianliebiao ul").animate(
			 		{
			 			"left":-picW * ($(".huxi1 .tupianliebiao li").length - 2)
			 		},500
			 	);
			}
			function shezhixiaoyuandian(y,nowshowpic){
				y.addClass("cur").siblings().removeClass("cur");
			}




			// 底部小圆点轮播
 		var picW1=188;
	$('.magazine .tupianliebiao ul li a').width(picW1-18);
	var nowshowpic = 0;
			//复制一个第一个li在最后，用于变魔术
			$(".magazine .tupianliebiao ul").each(function(){
				//$(this).html( $(this).html() + $(this).html() );
			});
			// $(".tupianliebiao ul").html( $(".tupianliebiao ul").html() + $(".tupianliebiao ul").html() );

			$(".magazine .rightanniu").click(
				function(){
					if(!$(".magazine .tupianliebiao ul").is(":animated")){
						if(nowshowpic == $(".magazine .tupianliebiao ul li").length - 2){
							nowshowpic = 0;
							lunboxianshim2();
						}else{
							nowshowpic = nowshowpic + 1;
							lunboxianshim(nowshowpic);
						}
						shezhixiaoyuandian(nowshowpic);
					}
				}
			);

			$(".magazine .leftanniu").click(
				function(){
					if(!$(".magazine .tupianliebiao ul").is(":animated")){
						if(nowshowpic == 0){
							nowshowpic = $(".magazine .tupianliebiao ul li").length - 2;
							lunboxianshim3();
						}else{
							nowshowpic = nowshowpic - 1;
							lunboxianshim(nowshowpic);
						}
						
						shezhixiaoyuandian(nowshowpic);
					}
				}
			);
			$(".magazine .xiaoyuandianul li").click(
				function(){
					var x=$(this);
					nowshowpic = $(this).index();
					lunboxianshim(x,nowshowpic);
					shezhixiaoyuandian(x,nowshowpic);
				}
			);

			function lunboxianshim(y,nowshowpic){
			 	y.parent().parent().siblings('.tupianliebiao').children('ul').animate(
			 		{
			 			"left":-y.parent().parent().siblings('.tupianliebiao').find('li').width()* nowshowpic
			 		},500
			 	);
			}

			function shezhixiaoyuandian(y,nowshowpic){
				y.addClass("cur").siblings().removeClass("cur");
			}











	// 论文细览页点击分享
	$('.doc-share-to').hide();
	$('.doc-share').hover(function() {
		$(this).children('a').addClass('cur');
		$('.doc-share-to').show();
	}, function() {
		$('.doc-share-to').hide();
		$(this).children('a').removeClass('cur');
	});

	/*===在线预览===*/
	// 点击收缩左侧栏
	$('.zk').attr('title','展开导航');
	$('.s-b-shrink').bind("click",function(){
			$(this).toggleClass('zk');
			$(this).siblings().toggleClass('hidden');
			$('.r-c-l').toggleClass('cur');
		}
	);



	// 视频音频库
	$('.media-library:gt(0)').hide();
	$('.media-l-t a').click(function(){
		$(this).addClass('cur').siblings().removeClass('cur');
		$('.media-library').eq($(this).index()).show().siblings('.media-library').hide();
	});


	// 期刊电子书
	$('.magazine:gt(0)').hide();
	$('.magazine-t a').click(function(){
		$(this).addClass('cur').siblings().removeClass('cur');
		$('.magazine').eq($(this).index()).show().siblings('.magazine').hide();
	});


});
